package com.crm.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crm.base.PageResponse;
import com.crm.base.PageResult;
import com.crm.domain.dto.CourseQueryDTO;
import com.crm.domain.entity.Course;
import com.crm.mapper.CourseMapper;
import com.crm.service.ICourseService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements ICourseService {

    @Autowired
    private CourseMapper courseMapper;

    /**
     * 分页查询课程信息
     * @param courseQueryDTO
     * @return
     */
    @Override
    public PageResult<List<Course>> courseByPage(CourseQueryDTO courseQueryDTO) {
        PageHelper.startPage(courseQueryDTO.getPageNum(), courseQueryDTO.getPageSize());

        Page<Course> page = courseMapper.page(courseQueryDTO);

        long total = page.getTotal();

        return PageResult.success("查询成功",page,total);
    }

}
